<template>
  <div class="home-container">
    <NavMenu :currentCategory="currentCategory" @changeCategory="changeCategory"></NavMenu>
    <div class="content">
      <div class="filter" v-show="currentCategory==='all'">
        <el-select-v2 placeholder="请输入标签类型" v-model="selectTags" :options="tagOptions" clearable
                      filterable multiple collapse-tags collapse-tags-tooltip :max-collapse-tags="3"/>
        <el-button type="primary">查询</el-button>
        <el-button type="primary" @click="uploadImg">上传</el-button>
      </div>
      <ImageContent :currentCategory="currentCategory"
                    :style="`height: ${currentCategory!=='all'?'100%':'calc(100% - 42px)'}`"></ImageContent>
    </div>

    <ImageUpload ref="imgUploadRef"></ImageUpload>
  </div>
</template>

<script lang="ts">
import {defineComponent, getCurrentInstance, reactive, ref, watch} from 'vue'
import NavMenu from '@/components/NavMenu.component.vue'
import ImageUpload from '@/components/ImageUpload.component.vue'
import ImageContent from '@/components/ImageContent.component.vue'
import {useCategoryStore} from '@/stores/category'

export default defineComponent({
  components: {NavMenu, ImageUpload, ImageContent},
  setup(props, {emit, attrs, slots}) {

    const instance: any = getCurrentInstance()

    // 菜单相关
    const currentCategory = ref('all')
    const changeCategory = (category: string) => {
      currentCategory.value = category
    }

    // 过滤相关
    const selectTags = ref([])
    const {categoryList: tagOptions} = useCategoryStore()

    // 上传相关
    const uploadImg = () => {
      instance.refs.imgUploadRef.openDialog()
    }

    return {
      currentCategory, changeCategory, selectTags, tagOptions,
      uploadImg
    }
  }
})
</script>
<style lang="less">
.home-container {
  height: 100%;
  padding: 15px 20px;
  display: flex;
  .content {
    width: calc(100% - 220px);
    background-color: #171d2d;
    .filter {
      margin: 0 10px 10px;
      .el-select-v2 {
        width: 320px;
        margin-right: 12px;
      }
    }
  }
}
</style>